from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 引入Keys包
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.maximize_window()
driver.get('file:///D:/nsd2404/html/registerA.html')

# 获取用户名文本框
username = driver.find_element(By.CSS_SELECTOR, '#userA')
username.send_keys('admin123')
# 退格
sleep(3)
username.send_keys(Keys.BACKSPACE)
# 全选（ctrl+a）
sleep(3)
username.send_keys(Keys.CONTROL, 'a')
# 执行ctrl+c
username.send_keys(Keys.CONTROL, 'c')
# 在密码框中执行ctrl+v
sleep(3)
password = driver.find_element(By.CSS_SELECTOR, '#passwordA')
password.send_keys(Keys.CONTROL, 'v')

sleep(3)
driver.find_element(By.CSS_SELECTOR, 'button').send_keys(Keys.ENTER)

sleep(3)
driver.quit()